<!doctype html>
<html lang="en">
<head> 
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>注册账号</title>
  <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <style>
    label, input { display:block; }
    input.text { margin-bottom:12px; width:95%; padding: .4em; }
    fieldset { padding:0; border:0; margin-top:25px; }
    div#users-contain { width: 350px; margin: 20px 0; }
    div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
    div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
    .ui-dialog .ui-state-error { padding: .3em; }
    .validateTips { border: 1px solid transparent; padding: 0.3em; }
  </style>
  <script src="https://code.jquery.com/jquery-3.4.1.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script src="https://shc7432.github.io/public/getLinkInput/getLinkInput.js"></script>
  <script src="https://shc7432.github.io/public/something/sometool.js"></script>
  <script src="https://shc0743.github.io/crypto-js/core.js"></script>
  <script src="https://shc0743.github.io/crypto-js/enc-base64.js"></script>
  <script src="https://shc0743.github.io/crypto-js/enc-hex.js"></script>
  <script src="https://shc0743.github.io/crypto-js/enc-utf8.js"></script>
  <script src="https://shc0743.github.io/crypto-js/enc-utf16.js"></script>
  <script src="https://shc0743.github.io/crypto-js/crypto-js.js"></script>
  <script src="https://shc0743.github.io/crypto-js/aes.js"></script>
  <script src="https://shc0743.github.io/crypto-js/md5.js"></script>
  <script src="https://shc0743.github.io/crypto-js/sha1.js"></script>
  <script src="https://shc0743.github.io/crypto-js/sha512.js"></script>
  <script src="https://shc7432.github.io/public/something/sometool.js"></script>
</head>

<body>

<h1>注册账号</h1>

<h2>准备好注册账号了吗?现在就开始吧!</h2>

<p onclick='$( "#newuser" ).dialog( "open" );'>点我即可注册</p>

<p hidden class="returnbutton">返回<span></span></p>

<div id="newuser" title="注册账号">
<fieldset>
<form id=frm>
账号<br>
<input type=text class="text ui-widget-content ui-corner-all" id=username maxlength=15><br>
密码<br>
<input type=text class="text ui-widget-content ui-corner-all" id=password maxlength=25><br>
<!--<button type=submit>马上注册!</button>-->
</form></fieldset></div>

<script id=srt1 type="test/javascript">
if(getUrlValue('returnto')){
document.querySelectorAll(".returnbutton")[0].hidden=0
document.querySelectorAll(".returnbutton")[0].querySelectorAll("span")[0].innerHTML=decodeURIComponent(getUrlValue("returnto"))
document.querySelectorAll(".returnbutton")[0].onclick=function(){location.href=decodeURIComponent(getUrlValue("returnto"))}
}

frm.onsubmit=usernew
function usernew(event){
  if(event!=undefined) event.preventDefault();
var xhtf=1
if(!localStorage.userdata) localStorage.userdata=JSON.stringify({data:[]})
while(xhtf){
xhtf--;

  if(username.value!=""&&password.value!=""&&username.value.search(",")==-1&&password.value.search(",")==-1){

if(localStorage.unme!=""&&localStorage.unme!=null){

var uunme=localStorage.userdata.data;
var i,out1=false
if(uunme!=""&&uunme!=null){

for(i=0;i<uunme.length;i++){
out1=out1||(username.value==uunme[i])
  }

} else {
//xhtf++;
var out1=false

}

}

if((!out1)){
      let ud=JSON.parse(localStorage.userdata);
      let pw=String(CryptoJS.MD5(password.value));
      ud.data.push({username: username.value,password: pw});
      ud=JSON.stringify(ud);
      localStorage.userdata=ud;
      $( "#diaok" ).dialog( "open" );
} else {
      $( "#diah" ).dialog( "open" );
}

  /*!=""*/} else {
      $( "#diac" ).dialog( "open" );
  }

/*while*/ }
          $( "#newuser" ).dialog( "close" );
/*function*/}  

$( function() {

    $( "#newuser" ).dialog({
      autoOpen: false,
      modal: true,
      buttons: {
        "注册": function() {
          usernew();
        },
        "取消": function() {
          $( "#newuser" ).dialog( "close" );
        }
      },
      close: function() {
        frm.reset()
        return false;
      }
    });
    $( "#diac" ).dialog({
      autoOpen: false,
      modal: true,
      buttons: {
        "知道了": function() {
          $( "#diac" ).dialog( "close" );
        }
      },
      close: function() {
        $( "#newuser" ).dialog( "open" );
        return false;
      }
    });
    $( "#diah" ).dialog({
      autoOpen: false,
      modal: true,
      buttons: {
        "好的": function() {
          $( "#diah" ).dialog( "close" );  
        } ,
        "好吧": function() {
          $( "#diah" ).dialog( "close" );
        }
      },
      close: function() {
        username.value=""
        $( "#newuser" ).dialog( "open" );
        return false;
      }
    });
    $( "#diaok" ).dialog({
      autoOpen: false,
      modal: true,
      buttons: {
        "完成": function() {
          $( "#diaok" ).dialog( "close" );
        } 
      },
      close: function() {
        $( "#newuser" ).dialog( "close" );
        return false;
      }
    });

  } );
</script>
<script>
try{eval(srt1.innerHTML)}
catch(err){alert(err)}
</script>
 
<div id="diac" title="注册失败">
  <p>请填写用户名和密码,用户名不要有逗号</p>
</div>
<div id="diah" title="注册失败">
  <p>已经有这个用户了,换一个吧QAQ</p>
</div>
<div id="diaok" title="注册成功">
  <p>恭喜您注册成功!!!</p>
</div>

</body>
</html>
